﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using EQual.Infrastructure.MVPFramework.Views;
using Microsoft.Practices.Composite.Events;

namespace EQual.MainModule.Projects.Tasks.Views
{
    /// <summary>
    /// Interaction logic for TasksGridView.xaml
    /// </summary>
    public partial class TasksGridView : UserControl ,IListView <object ,object >
    {
        public TasksGridView()
        {
            InitializeComponent();
        }

        private void dataGrid1_RowEditEnding(object sender, Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs e)
        {

            if (ItemAdded != null)
                ItemAdded(this, new DataEventArgs<object>(GetActiveItem()));
        }

        private object GetActiveItem()
        {
            return this.dataGrid1.SelectedItem;

        }

        private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }


        public object  Model
        {
            get { return this.DataContext; }
            set { this.DataContext = value;
            }
        }


        #region IListView<object,object> Members


        public event EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>> ItemSelected;

        public event EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>> ItemDeleted;

        public event EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>> ItemAdded;

        #endregion
    }
}
